<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="UTF-8" />
<title>应急救援管理系统</title>
<link th:href="@{../assets/css/bootstrap.css}" rel="stylesheet" />
	<link rel="shortcut icon" th:href="@{../assets/img/favicon.ico}"/>
<script type="text/javascript" th:src="@{../assets/libs/jquery/dist/jquery.js}"></script>
<script type="text/javascript" th:src="@{../assets/libs/bootstrap/dist/js/bootstrap.js}"></script>
<script type="text/javascript" th:src="@{../assets/libs/backstretch/jquery.backstretch.js}"></script>
<script type="text/javascript" th:src="@{../assets/js/login/jquery.md5.js}"></script>
<script type="text/javascript" th:src="@{../assets/js/login/jquery.tips.js}"></script>
<style>
body {
	padding: 0px;
	margin: 0px;
}

.container {
	margin-top: 230px;
	margin-right: 200px;
}

.form-bg {
	background: #00b4ef;
}

.form-horizontal {

	background: #58636F;
	padding-bottom: 10px;
    border-radius: 0px;
	text-align: left;
}

.form-horizontal .heading {
	display: block;
	font-size: 24px;
	font-weight:bold;
	color:#FFFFFF;
 	padding: 10px 10px 20px 40px ;
	border-bottom: 0px solid #f0f0f0;
	margin-bottom: 10px;
}

.form-horizontal .form-group {
	padding: 0 40px;
	margin: 0 0 25px 0;
	position: relative;
}

.form-horizontal .form-control {
	background: #f0f0f0;
	border: none;
	border-radius: 20px;
	box-shadow: none;
	padding: 0 20px 0 45px;
	height: 40px;
	transition: all 0.3s ease 0s;
}

.form-horizontal .form-control:focus {
	background: #e0e0e0;
	box-shadow: none;
	outline: 0 none;
}

.form-horizontal .form-group i {
	position: absolute;
	top: 12px;
	left: 60px;
	font-size: 17px;
	color: #c8c8c8;
	transition: all 0.5s ease 0s;
}

.form-horizontal .form-control:focus+i {
	color: #00b4ef;
}

.form-horizontal .fa-question-circle {
	display: inline-block;
	position: absolute;
	top: 12px;
	right: 60px;
	font-size: 20px;
	color: #808080;
	transition: all 0.5s ease 0s;
}

.form-horizontal .fa-question-circle:hover {
	color: #000;
}

.form-horizontal .main-checkbox {
	float: left;
	width: 20px;
	height: 20px;
	background: #11a3fc;
	border-radius: 50%;
	position: relative;
	margin: 5px 0 0 5px;
	border: 1px solid #11a3fc;
}

.form-horizontal .main-checkbox label {
	width: 20px;
	height: 20px;
	position: absolute;
	top: 0;
	left: 0;
	cursor: pointer;
}

.form-horizontal .main-checkbox label:after {
	content: "";
	width: 10px;
	height: 5px;
	position: absolute;
	top: 5px;
	left: 4px;
	border: 3px solid #fff;
	border-top: none;
	border-right: none;
	background: transparent;
	opacity: 0;
	-webkit-transform: rotate(-45deg);
	transform: rotate(-45deg);
}

.form-horizontal .main-checkbox input[type=checkbox] {
	visibility: hidden;
}

.form-horizontal .main-checkbox input[type=checkbox]:checked+label:after
	{
	opacity: 1;
}

.form-horizontal .text {
	float: left;
	margin-left: 7px;
	line-height: 20px;
	padding-top: 5px;
	text-transform: capitalize;
}

.form-horizontal .btn {
	float:right;
	font-size: 20px;
	font-weight:bold;
	width: 280px;
	height: 40px;
	color: #fff;
	background: #BC0001;
	border-radius: 20px;
	padding: 5px 25px;
	border: none;
	text-transform: capitalize;
	transition: all 0.5s ease 0s;
}

@media only screen and (max-width: 479px) {
	.form-horizontal .form-group {
		padding: 0 25px;
	}
	.form-horizontal .form-group i {
		left: 45px;
	}
	.form-horizontal .btn {
		padding: 10px 20px;
	}
}
</style>
</head>
<body  style="width:100%; background-size:cover;overflow:hidden; background-repeat:repeat-x;    ">
<div class="container">
		<div class="row">
			<div class="col-md-offset-8 col-md-4"  id="loginbox">
				<form class="form-horizontal" action="#"  id="loginForm">
					<span class="heading">用户登录</span>
					<div class="form-group">
						<input type="text" class="form-control" id="loginname" name="loginname" placeholder="用户名" onkeydown="var e=window.event || arguments[0];if(e.keyCode==13){ severCheck() }"/> <i class="fa fa-user"></i>
					</div>
					<div class="form-group help">
						<input type="password" class="form-control" id="password" name="password" placeholder="密　码" onkeydown="var e=window.event || arguments[0];if(e.keyCode==13){ severCheck() }"/> <i class="fa fa-lock"></i> <a href="#" class="fa fa-question-circle"></a>
					</div>
					<div class="form-group">
						<!--<div class="main-checkbox">
							<input type="checkbox" value="None" id="checkbox1" name="check" /> <label for="checkbox1"></label>
						</div>
						<span class="text">Remember me</span>-->
						<button type="button" id="sub" class="btn btn-default" onclick="severCheck() "> 登&nbsp; &nbsp;录 </button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript">
        //服务器校验
        function severCheck() {
            if (check()) {
                var loginname = $("#loginname").val();
                var password = jQuery.md5($("#password").val());
                $.ajax({
                    type : "post",
                    url : "../login/checkUserLogin",
                    data : {
                        loginname : loginname,
                        loginpwd : password
                    },
                    dataType : "json",
                    cache : false,
                    success : function(data) {
                        if (0 == data.retcode) {
                            saveCookie();
                            $("#sub").removeAttr("disabled");
                            window.location.href = "../main/index";
                        } else {
                            $("#loginname").tips({
                                side : 1,
                                msg : data.retmsg,
                                bg : "#FF5080",
                                time : 15
                            });
                            $("#sub").removeAttr("disabled");
                            $("#loginname").focus();
                        }
                    }
                });
            }
        }
        function saveCookie() {
            if ($("#saveid").attr("checked")) {
                $.cookie("loginname", $("#loginname").val(), {
                    expires : 7
                });
                $.cookie("password", $("#password").val(), {
                    expires : 7
                });
            }
        }
        $(document).ready(function() {
            changeCode();
            $("#codeImg").bind("click", changeCode);
        });

        $(document).keyup(function(event) {
            if (event.keyCode == 13) {
                $("#to-recover").trigger("click");
            }
        });

        function genTimestamp() {
            var time = new Date();
            return time.getTime();
        }

        function changeCode() {
            //$("#codeImg").attr("src", "code.do?t=" + genTimestamp());
        }

        //客户端校验
        function check() {
            $("#sub").attr({"disabled":"disabled"});
            if ($("#loginname").val() == "") {
                $("#loginname").tips({
                    side : 2,
                    msg : "用户名不得为空",
                    bg : "#AE81FF",
                    time : 3
                });
                $("#sub").removeAttr("disabled");
                $("#loginname").focus();
                return false;
            } else {
                $("#loginname").val(jQuery.trim($("#loginname").val()));
            }

            if ($("#password").val() == "") {

                $("#password").tips({
                    side : 2,
                    msg : "密码不得为空",
                    bg : "#AE81FF",
                    time : 3
                });
                $("#sub").removeAttr("disabled");
                $("#password").focus();
                return false;
            }

            $("#loginbox").tips({
                side : 2,
                msg : "正在登录 , 请稍后 ...",
                bg : "#68B500",
                time : 10
            });
 			$("#sub").removeAttr("disabled");
            return true;
        }


	</script>
	<script th:inline="javascript">
		var imgBaseUrl= [[@{/}]]+"/../assets/img/login/";
		 $.backstretch([ imgBaseUrl+"banner_slide_01.png"], {

		});

	</script>
</body>
</html>